package com.abel.roommanager.provider;

import java.util.Map;

import org.apache.ibatis.jdbc.SQL;

import com.abel.roommanager.pojo.Student;

public class StudentsSql {
   public String getFindStudentSql(Map<String, Object> map) {
	   Student student=(Student) map.get("student");
	   int index=(int) map.get("index");
	   int count=(int)map.get("count");
	   SQL sql=new SQL().SELECT("*").FROM("student");
	   if (student.getSname()!=null&&student.getSname().length()!=0) {
		sql.WHERE("sname like '"+student.getSname()+"'");
	}
	   if (student.getCid()!=0) {
		sql.WHERE("cid="+student.getCid());
	}
	   if (student.getRoomno()!=0) {
		sql.WHERE("roomno="+student.getRoomno());
	}
	   
	   String sqlString=sql.toString();
	   sqlString=sqlString+" limit "+index+","+count;
	   return sqlString;
	
}
}
